/*
 * @Author: 春天被折进纸里 3301231308@qq.com
 * @Date: 2024-03-07 15:21:02
 * @LastEditors: 春天被折进纸里 3301231308@qq.com
 * @LastEditTime: 2024-04-01 10:53:10
 * @FilePath: \visual-large-screen\vite.config.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import postcssPxtoRem from 'postcss-pxtorem'

export default defineConfig({
  plugins: [vue()],
  resolve: {
    // Vite路径别名配置
    alias: {
      "@": path.resolve("./src"),
    },
  },
  // 引入公共样式方式
  css: {
    preprocessorOptions: {
      scss: {
        // additionalData: ` @import "@/style/common.scss";`,
      },
    },
    postcss: {
      plugins: [
        postcssPxtoRem({
          rootValue: 192, // 按照自己的设计稿修改 1920/10
          unitPrecision: 5, // 保留到5位小数
          selectorBlackList: [""],  // 忽略转换正则匹配项 过滤掉.el-开头的class，不进行rem转换
          propList: ['*'], // 除 border 外所有px 转 rem
          replace: true,
          mediaQuery: false,
          minPixelValue: 0
        })
      ]
    }
  },
  server: {
    history: true,
    host: "0.0.0.0",
    port: "8033",
    open: true,
    fs: {
      strict: true,
    },
    cors: true, // 允许跨域
    proxy: {
      '/api': {
        target: 'http://localhost:8033',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      },
    },
  },
});
